"""
Script to display a summary of output from python2.6 -3
(as the output is not nice to analyse)

e.g

python2.6 -3 ButtonBox_test.py 2>&1 | python2.6 -m ppande.py3stats

a dictionary of files with a dictionary of errors and a list of line numbers is output
a total error count and summary list of errors is also output
"""
import sys

db= {}
db2 = set()
count = 0
for l in sys.stdin:
    if l.startswith('/'):
        count += 1
        f, line, what = l.strip().split(':', 2)
        db.setdefault(f, {}).setdefault(what, []).append(line)
        db2.add(what)


for f in sorted(db):
    print f
    for error in sorted(db[f]):
        print '\t', error
        print '\t\t', sorted([int(i) for i in db[f][error]])
        
print 'Total errors:', count
print 'Summary:'
for error in sorted(db2):
    print '\t',error
